﻿<%@ Page Title="" Language="C#" MasterPageFile="~/module/Fontend.Master" AutoEventWireup="true" CodeBehind="AlbumClip.aspx.cs" Inherits="mamnontuoitho7.module.AlbumClip" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
 <script language="javascript" type="text/javascript">

     function ClientComment_Click() {

         var commentContent = trim(document.getElementById("<%= txtComment.ClientID %>").value);
         var leng = commentContent.length;
         if (leng < 10 || leng > 600) {
             alert("Cần gõ hơn 10 ký tự và không quá 600 ký tự");
             return false;
         }
     }
     function CommentUpdate(i) {
         var commentContent = trim(document.getElementById("txtNewComment" + i).value);
         var leng = commentContent.length;
         if (leng < 10 || leng > 600) {
             alert("Cần gõ hơn 10 ký tự và không quá 600 ký tự");
             return false;
         }
     }
     function trim(str) {
         return str.replace(/^\s+|\s+$/g, "");
     }
    </script>
<div class="orange"><a href="Home.aspx">Trang chủ</a> &raquo; Video Clip &raquo; <%=_general.ReplaceSpecialCharacters(_dt.Rows[a]["Title"].ToString())%></div>
<div class="albumdescription">
    <p>
        <%=_general.ReplaceSpecialCharacters(_dt.Rows[a]["Introduce"].ToString())%>
    </p>
</div>
<div class="clip">
    <iframe src="http://www.youtube.com/embed/<%=_dt.Rows[a]["VideoURL"].ToString()%>"
      width="640" height="390" frameborder="0" allowfullscreen wmode="Opaque"></iframe>
</div>
<div class="cliplist">
    <h1 class="h1_orange">Video khác:</h1>
    <div class="albumclip">
        <div class="f-link-all">
            <div class="move">
                <a href="javascropt:;" class="left prevsalec"></a><a href="javascropt:;" class="right nextsalec">
                </a>
            </div>
        </div>
        <div class="sliderc">

         <%  int  c;// là số lượng record trong 1 div
               int b = _dt.Rows.Count;
               for (int i = 0; i < b; i++)
               {
           %>
                <div>
                  <ul>
                    <%
                        if (i + 6 > b)// xác định div cuối
                        {
                            c = b % 6;  // số lượng record trong div cuối(trường hợp này là 3 record 1 div)
                        }
                        else
                        {
                            c = 6;
                        }
                    int j;
                    for ( j = 0; j < c;j++,i++ )
                      {
                          if (_dt.Rows[i]["ProductID"].ToString() != _productID)
                          {
                    %>
                
                    <li><%--<input type="submit" value="Tên chủ đề clip 1" class="buttons"/>--%>
                        <a href="AlbumClip.aspx?clipID=<%=_dt.Rows[i]["ProductID"].ToString()%>" class="buttons"><%=_general.CutString(_general.ReplaceSpecialCharacters(_dt.Rows[i]["Title"].ToString()), 70)%></a><span>(<%= DateTime.Parse(_dt.Rows[i]["PostDate"].ToString()).ToString("dd/MM/yyyy")%>)</span>
                    </li>
                
            <%
                          }  
                     }
                        if (j == 6)//chạy xong for trong div.
                            i = i - 1;//phải giảm i 1 don vị, vì i++ xảy ra 2 lần
                    %>
                    </ul>
                </div>
                <%} %>
                <div></div>
        </div>
    </div>
</div>

    <form id="form1" runat="server">
        <div class="articlemore" style="margin-top: -30px;">
        <h1 class="h1_orange">
            Bình luận album:</h1>
        <div class="articlecomment">
            <asp:TextBox TextMode="MultiLine" ID="txtComment" runat="server"></asp:TextBox>
            <% if (Session["username"] != "")
            { %>
            <asp:Button ID="btnPostComment" runat="server" CssClass="buttons" 
                Text="Bình luận" onclick="btnPostComment_Click" OnClientClick="return ClientComment_Click()"/>
            <% }
            else
            {%>
            <a href="#loginform" onclick="showhide('loginform');" class="buttons">Đăng nhập</a>
            <%} %>
        </div>
    </div>
    </form>
    <%
        int _commentAmount = _dtComment.Rows.Count;
      %>  

      <input type="hidden" id="hihCommentAmount" value="<%= _commentAmount%>" />  <%--biến cầu nối chay js tren fontend--%>
    <%
        for (int i = 0; i < _commentAmount; i++)
        {
    %>
    <div class="commentdetail">
        <img src="../images/avatar/teacher_parents/<%= (_dtComment.Rows[i]["Avatar"].ToString() != "") ? _dtComment.Rows[i]["Avatar"].ToString() : "icon-avatar.png" %>" alt="<%= (_dtComment.Rows[i]["Avatar"].ToString() != "") ? _dtComment.Rows[i]["Avatar"].ToString() : "Mam non tuoi tho 7" %>" />
        <span class="arrow"><span></span></span>
        <div id="showcontent<%= i%>" class="blockcontent">
            <div class="content">
                <%= _general.ReplaceSpecialCharacters(_dtComment.Rows[i]["ContentComment"].ToString())%>
            </div>
            <div class="info">
                bởi <a href="ProfileInfo.aspx?MemberID=<%=_dtComment.Rows[i]["MemberID"].ToString() %>"  class="groupprofile">
                    <%= _dtComment.Rows[i]["FullName"].ToString()%></a> lúc:
                <%= DateTime.Parse(_dtComment.Rows[i]["CreateDate"].ToString()).ToString("dd/MM/yyyy HH:mm:ss")%>
                <% bool tempbool = _comment.checkCommentOwner(Session["username"].ToString(), _dtComment.Rows[i]["CommentID"].ToString());
                   if (tempbool)
                   { %>
                <a href="#editcontent" onclick="hide('showcontent<%= i%>'); showhide('editcontent<%= i%>');" class="buttonlink">Sửa</a>
                  <%} %>
                   <%if (Session["role"].ToString()=="1" ||Session["role"].ToString()=="2" ||Session["role"].ToString()=="5" ||Session["role"].ToString()=="7")
                    
                    { %>
                       <a href="AlbumClip.aspx?clipID=<%=_productID%>&b=<%= _dtComment.Rows[i]["CommentID"].ToString()%>&page=<%=_pageflag %>"  class="buttonlink" onclick="javascript: if (confirm('Bạn muốn xóa comment này?')) { window.location.href='#' } else { return false; };">
                            Xóa
                       </a>
                  <%} %>
             </div>
        </div>
        <div id="editcontent<%= i%>" class="blockcontent">
        <% if (tempbool){ %>
        <form method="post" action="AlbumClip.aspx?clipID=<%=_productID%>&page=<%=_pageflag %>" id="formUpdate">
            <div class="content">
                <textarea id="txtNewComment<%= i%>" name="txtNewComment" class="textarea"><%= _dtComment.Rows[i]["ContentComment"].ToString()%></textarea>
                <input type="hidden" id="hidCommentID" name="hidCommentID" value="<%= _dtComment.Rows[i]["CommentID"].ToString()%>" />
                <input type="hidden" id="hidStatus" name="hidStatus" value="1" />
            </div>
            <div class="info">
                bởi <a href="ProfileInfo.aspx?MemberID=<%=_dtComment.Rows[i]["MemberID"].ToString() %>"  class="groupprofile">
                    <%= _dtComment.Rows[i]["FullName"].ToString()%></a> lúc:
                    <%= DateTime.Parse(_dtComment.Rows[i]["CreateDate"].ToString()).ToString("dd/MM/yyyy HH:mm:ss")%>
                <a href="#showcontent" onclick="hide('editcontent<%= i%>'); showhide('showcontent<%= i%>');" class="buttonlink">Hủy</a>
                 <button type="submit" class="buttoncomment" onclick="return CommentUpdate(<%= i%>)">Cập nhật </button>
            </div>
        </form>
        <%} %>
        </div>
      
           
    </div>
    <% }%>
    
    <%--<div class="commentdetail">
        <img src="../images/avatar/teacher_parents/icon-avatar.png" alt="" />
        <span class="arrow"><span></span></span>
        <div id="showcontent" class="blockcontent">
            <div class="content">
                đây là nội dung bài bình luận
            </div>
            <div class="info">
                bởi <a href="#">Sky Lee</a> lúc: 21/08/2012 10:09:29 AM
                <a href="#editcontent" onclick="hide('showcontent'); showhide('editcontent');" class="buttonlink">Sửa</a></div>
        </div>
        <div id="editcontent" class="blockcontent">
            <div class="content">
                <textarea id="txtNewComment" name="txtNewComment" class="textarea">đây là nội dung bài bình luận</textarea>
            </div>
            <div class="info">
                bởi <a href="#">Sky Lee</a> lúc: 21/08/2012 10:09:29 AM
                <a href="#showcontent" onclick="hide('editcontent'); showhide('showcontent');" class="buttonlink">Hủy</a>
                <input type="button" value="Cập nhật" class="buttoncomment" /></div>
        </div>
    </div>--%>
    
    <div id="container">
        <div class="pagination">
            <%if (_currentbar > 1)
              { %>
            <a href="AlbumClip.aspx?a=-1&clipID=<%=_productID%>" class="pageorange"><<</a>
            <%} %>
            <%  

                for (int j = _beginPage; j <= _endPage; j++)
                {
                    if (j == _pageflag)
                    {
            
            %>
            <a href="AlbumClip.aspx?page=<%= j%>&clipID=<%=_productID%>" class="pageorange active"><%= j%></a>
            <% }
                    else
                    { %>
            <a href="AlbumClip.aspx?page=<%= j%>&clipID=<%=_productID%>" class="pageorange"><%= j%></a>
            <%  }
                } %>
            <%if (_currentbar < _totalBars)
              { %>
            <a href="AlbumClip.aspx?a=1&clipID=<%=_productID%>" class="pageorange">>></a>
            <%} %>
          
        </div>
    </div>

    <%--<div id="container">
        <div class="pagination">
            <a href="#" class="pageorange"><<</a>
            <a href="#" class="pageorange">2</a>
            <a href="#" class="pageorange">3</a>
            <span class="pageorange active">4</span>
            <a href="#" class="pageorange">5</a>
            <a href="#" class="pageorange">6</a>
            <a href="#"class="pageorange">>></a>
        </div>
    </div>--%>
</asp:Content>
